package DP;

/**
 * @author 曹见朋
 * @create 2024-06-12-23:44
 */
public class Main518 {
    // TODO 518. 零钱兑换 II

    public static int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];

        int n = coins.length;
        dp[0] = 1;
        for(int i = 0; i < n; i++){
            for(int j = coins[i]; j <= amount; j++){
                dp[j] = dp[j] + dp[j - coins[i]];
            }
        }
        return dp[amount];
    }

    public static void main(String[] args) {
        int[] coins = new int[]{1, 2, 5};
        int amount = 5;
        int change = change(amount, coins);
        System.out.println(change);
    }
}
